<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Main extends MY_Controller {
	
	/**
	 * 'link'=>'name' menu entries
	 * @var array
	 */
	private $menuItems = array (
		'Main/index'				=>	'home',
		'Main/link1'				=>	'Codeigniter',
		'Main/link2'				=>	'jQuery',
		'Main/about'				=>	'about',
		'welcome/index'				=>	'welcome',
	);
	
	
	/**
	 * array with partials view  
	 * @var array
	 */
	var $partials = array(
		'header'				=>'main/partials/mainHeader',
		'footer'				=>'main/partials/mainFooter'
	);
	
	/**
	 * Constructor
	 */
	function Main() {
		parent::__construct();
		
		// load ...
		$this->load->helper(array('html'));
		$this->load->library(array('template','carabiner','fuelmenu','ion_auth'));
		$this->load->model('Main_model');
		
		$this->carabiner->css(array('reset.css','main.css'));
			
		$this->_configTemplate();
	}
	
	/**
	 * Config the template data
	 */
	private function _configTemplate() {
		$this->template->title('Main');
		$this->template->enable_parser(false);
		$this->template->set_layout('mainLayout');
		$this->template->set_partial('header', $this->partials['header']);
		$this->template->set_partial('footer', $this->partials['footer']);
	}
	
	/**
	 * Create main navigation menu
	 */
	private function _createNavigationMenu() {
		
		// set this link with class="current"
		$active = $this->uri->rsegment(1).$this->uri->slash_rsegment(2,'leading');
		$this->firephp->log($active,'active');
		
		$param = array(
			'active_class'			=>'current',
			'use_titles'			=>false,
			'container_tag_class'	=>'menu',
		);
		
		$this->fuelmenu->initialize($param);
		
		// render the menu
		$menu = $this->fuelmenu->render($this->menuItems,$active,NULL,'basic');
		
		return $menu;
	}
	
	
	
	
	
	
	public function index() {
		
		$this->template->set('groupLibraries', array('jquery','html-kickstart'));
		
		$this->template->set('mainMenu',$this->_createNavigationMenu());
		
		$this->template->build('main/content/mainBodyHome');
	}
	
	public function link1() {
		$this->template->set('groupLibraries', array('jquery','html-kickstart'));
		
		$this->template->set('mainMenu',$this->_createNavigationMenu());
		
		$this->template->build('main/content/mainBodyCI');
	}
	
	public function link2() {}
	
	public function about() {}
	
	private function _tmp() {}
	
	
	
	
	
	
	
	public function tmp() {
		//$this->Main_model->tmp();
		$menu = $this->_createNavigationMenu();
		$this->firephp->log($menu,'menu');
	}
	
}
